package com.zzhua.quartz.job;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.SimpleDateFormat;

public class HelloJob implements Job {

    @Autowired
    HelloService helloService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        System.out.println("ActionJob：启动任务=======================");
        run();
        System.out.println("ActionJob：下次执行时间====="+
                new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
                        .format(context.getNextFireTime())+"==============");
    }
    public void run(){
        System.out.println("获取到spring容器中的bean: " + helloService);
        helloService.hello();
        System.out.println("Hello job is running...");
    }
}